<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:display="http://www.w3.org/1999/xhtml" xmlns:div.display="http://www.w3.org/1999/xhtml"
      xmlns:row.display="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>applyInfo</title>

    <!-- Bootstrap Core CSS -->
    <link th:href="@{/vendor/bootstrap/css/bootstrap.min.css}" href="../static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <link th:href="@{/vendor/metisMenu/metisMenu.min.css}" rel="stylesheet">

    <!-- Custom CSS -->
    <link th:href="@{/dist/css/sb-admin-2.css}" rel="stylesheet">

    <!-- Custom Fonts -->
    <link th:href="@{/vendor/font-awesome/css/font-awesome.min.css}" rel="stylesheet" type="text/css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>


<!-- Bootstrap Core JavaScript -->
    <script th:src="@{/vendor/jquery/jquery.min.js}" src="../../static/vendor/jquery/jquery.min.js"></script>
    <script th:src="@{/vendor/bootstrap/js/bootstrap.min.js}"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script th:src="@{/vendor/metisMenu/metisMenu.min.js}"></script>

    <!-- Custom Theme JavaScript -->
    <script th:src="@{/dist/js/sb-admin-2.js}"></script>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript">
        function applyInfoSubmit()
        {
            var userid = $("#userid").val();
            var loanid = $("#loanid").val();
            var stepcode = "填写申请";
            var result =$("#result").val();
            var actiondate =getNowFormatDate();


            $.ajax({
                type: "POST",
                url: "/applyInfoSubmit",
                contentType: "application/json",
                data: JSON.stringify({
                    userid: userid.toString(),
                    loanid: loanid.toString(),
                    stepcode:stepcode.toString(),
                    result:result.toString(),
                    actiondate:actiondate.toString()
                }),
                success: function (data) {
                    alert("审批完成，自动刷新网页");
                    $("#table_workflow").submit();
                    parent.location.reload();

                }
            })
        }

        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
                + " " + date.getHours() + seperator2 + date.getMinutes()
                + seperator2 + date.getSeconds();
            return currentdate;
        }
    </script>




</head>
<body>
<div  id ="applyInfo"  >
    <div class="col-lg-12">
        <form   name="applyInfo" id="table_workflow" th:action="@{/applyInfo(loanid=${loanid},userid=${userid})}"  method="post"  >
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <div class="row">
                        <div class="col-lg-6">
                            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">工作流程记录</a>
                            <button type="submit" class="btn btn-primary">刷 新</button>
                            <button type="button" class="btn btn-primary">取消贷款</button>
                        </div>
                        <div class="col-lg-3">
                            <lable>当前步骤：填写申请</lable>
                        </div>
                        <div class="col-lg-3">
                            <lable>工作流状态：运行中</lable>
                            </div>



                        </div>
                    </h4>


                </div>
                <div id="collapseOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div class="row" >
                            <div class="tableinfo">
                                <table  class="table" border="1" >
                                    <tr>
                                        <th>日期</th>
                                        <th>用户</th>
                                        <th>步骤</th>
                                    </tr>
                                    <tr th:each="WorkFlow : ${applyInfo_info.Workflow}">
                                        <td th:text="${WorkFlow.ACTIONDATE}"></td>
                                        <td th:text="${WorkFlow.ACTIONUSER}"></td>
                                        <td th:text="${WorkFlow.STEPCODE}"></td>
                                    </tr>
                                </table>
                            </div>

                        </div>


                    </div>
                </div>
            </div>



        </form>
    </div>
</div>
<div class="col-lg-12">
    <form   name="applyInfo" th:action="@{/applyInfo}"  method="post"  >
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4 class="panel-title">
                <div class="row">
                    <div class="col-lg-6">
                        <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">填写申请</a>
                        <button type="button" class="btn btn-primary" onclick="applyInfoSubmit()">提 交</button>
                    </div>
                </div>
            </h4>


        </div>
        <div id="collapseTwo" class="panel-collapse collapse in">
            <div class="panel-body">
                <div class="row" >
                <div class="col-lg-2">
                    <label>主状态：</label>
                </div>
                <div class="col-lg-2">
                    <input class="form-control"  value="Application In Progress" disabled  >
                </div>
            </div>
                <div class="row" >
                    <div class="col-lg-2">
                        <label>优先权：</label>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control"  id="" required>
                            <option value="1">正常</option>
                            <option value="2">最低</option>
                            <option value="3">最高</option>
                        </select>
                    </div>
                </div>
                <div class="row" >
                    <div class="col-lg-2">
                        <label>选择：</label>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control" id="result" required>
                            <option value="1">额度申请提交</option>
                            <option value="2">租赁申请提交</option>
                        </select>
                    </div>
                </div>

                <div class="row" >
                    <input th:value="${userid}" id="userid" style="display: none">
                    <input th:value="${loanid}" id="loanid" style="display: none">
                </div>


            </div>
        </div>
    </div>



</form>
</div>
</body>
</html>